home *** CD-ROM | disk | FTP | other *** search
/ PC Format (PL) 2008 March / PCFormat 3_2008.iso / Multimedia / Miro 1.0 / Miro_Installer.exe / resources / dtvapi.js < prev    next >
Text File  |  2007-11-12  |  2KB  |  59 lines

  1. /*
  2. # Miro - an RSS based video player application
  3. # Copyright (C) 2005-2007 Participatory Culture Foundation
  4. #
  5. # This program is free software; you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation; either version 2 of the License, or
  8. # (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program; if not, write to the Free Software
  17. # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  18. */
  19.  
  20. var dtvapiSitePart = null;
  21.  
  22. function dtvapiInitialize(cookie) {
  23.     dtvapiSitePart = "http://127.0.0.1:" + cookie;
  24. }
  25.  
  26. function dtvapiAddChannel(url) {
  27.     // alert("dtvapiAddChannel " + url);
  28.     dtvapi_doSend("/dtv/dtvapi/addChannel?" + url);
  29. }
  30.  
  31. function dtvapiGoToChannel(url) {
  32.     // alert("dtvapiGoToChannel " + url);
  33.     dtvapi_doSend("/dtv/dtvapi/goToChannel?" + url);
  34. }
  35.  
  36. function dtvapi_doSend(request) {
  37.     if (dtvapiSitePart) {
  38.         request = dtvapiSitePart + request;
  39.         // alert("DTVAPI sending " + request);
  40.         /*
  41.           var req = new XMLHttpRequest();
  42.           req.open("GET", request, false);
  43.           req.send(null);
  44.         */
  45.  
  46.         // We are loaded from the channel guide, so we don't fall
  47.         // under the same-origin exemption and can't XMLHttpRequest to
  48.         // 127.0.0.1. No matter; drive our truck through the large
  49.         // hole in the browser security model.
  50.         elt = document.createElement("script");
  51.         elt.src = request;
  52.         elt.type = "text/javascript";
  53.         document.getElementsByTagName("head")[0].appendChild(elt);
  54.     }
  55.     else {
  56.         dump("DTVAPI: Can't send request (not initialized): " + request);
  57.     }
  58. }
  59.